package com.example.service;

import com.example.entity.HotBooks;
import com.example.entity.HotHistory;
import com.example.mapper.HotHistoryMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*
热门历史业务处理
 */
@Service
public class HotHistoryService {

    @Resource
    private HotHistoryMapper hotHistoryMapper;

    public void add(HotHistory hotHistory) {
        hotHistoryMapper.insert(hotHistory);
    }

    public void deleteById(Integer id) {
        hotHistoryMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(HotHistory hotHistory) {
        hotHistoryMapper.updateById(hotHistory);
    }

    public HotHistory selectById(Integer id) {
        return hotHistoryMapper.selectById(id);
    }

    public List<HotHistory> selectAll(HotHistory hotHistory) {
        return hotHistoryMapper.selectAll(hotHistory);
    }

    public PageInfo<HotHistory> selectPage(HotHistory hotHistory, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<HotHistory> hotHistoryList = hotHistoryMapper.selectAll(hotHistory);
        return PageInfo.of(hotHistoryList);
    }
}
